import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;


public class GameModeForm extends List implements CommandListener {

	private DisplayController m_Controller;
	
	public GameModeForm(DisplayController ctrl) {
		super("Game Mode", List.IMPLICIT);
		m_Controller = ctrl;
		init();
	}

	private boolean m_IsServer;
	private Command c2;
	private Command c1;

	public void init() {
		c1 = new Command("Server", Command.ITEM, 0);
		this.addCommand(c1);
		c2 = new Command("Client", Command.ITEM, 0);
		this.addCommand(c2);
		this.setCommandListener(this);		
	}

	public boolean isServer() {
		return m_IsServer;
	}

	public void setServer(boolean isServer) {
		this.m_IsServer = isServer;
	}

	public void commandAction(Command c, Displayable arg1) {
		if (c.equals(c1)) {
			m_IsServer = true;
			m_Controller.setCurrentDisplay(new ServerConnectionForm("Server", m_Controller));
		} else if (c.equals(c2)) {
			m_IsServer = false;
			m_Controller.setCurrentDisplay(new ClientConnectionForm("Client", m_Controller));
		}
	}
}
